TARGET:=Lemure
all: $(TARGET)

.PHONY: all clean install

CFLAGS=-DNDEBUG -g -Wall -DMONGO_HAVE_STDINT
#CFLAGS=-DDEBUG -g -Wall 

LIBS=-lpthread -L /usr/local/lib -L ../mongodb_c_driver -levent -llua -ldl -lmongocclient 
SOURCES:=$(wildcard *.cpp) $(wildcard common/*.cpp)	$(wildcard db/*.cpp) $(wildcard aoi/*.cpp)
INCLUDE:=-I. -I./common -I./aoi -I./db -I../mongodb_c_driver 
DEPENDS:=$(SOURCES:.cpp=.d)
OBJECTS:=$(SOURCES:.cpp=.o)
sinclude $(DEPENDS)

$(TARGET):$(OBJECTS)
	$(CXX) -o $@ $^ $(LIBS)

$(OBJECTS):%.o:%.cpp
	$(CXX) -c $(CFLAGS) $(CPPFLAGS) $(INCLUDE) $< -o $@

$(DEPENDS):%.d:%.cpp
	$(CXX) -MM $(CFLAGS) $(CPPFLAGS) $(INCLUDE) $< > $@.$$$$; \
	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
	rm -f $@.$$$$

clean:
	rm -f $(TARGET) $(OBJECTS) $(DEPENDS)

install:
	cp $(TARGET) ../bin
